//
//  ClubEmptyView.swift
//  77Club
//
//  Created by Apple on 2024/9/11.
//

import UIKit

class ClubEmptyView: UIView {

    private let iconImageView = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).image("Common_empty").end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color("#2E3033").font(14.font_semiBold).alignment(.center).end()
    
    var titleString: String = "" {
        didSet{
            titleLabel.text = titleString
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = .clear
        
        subviews{
            iconImageView
            titleLabel
        }
        
        iconImageView.top(0).width(197.0.Scale).height(150.0.Scale).centerHorizontally()
        titleLabel.leading(20).trailing(20)
        titleLabel.Top == iconImageView.Bottom + 24.0.Scale
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ClubEmptyCommitView: UIView {

    private let iconImageView = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).image("Common_commitEmpty").end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color("#2E3033").font(14.font_semiBold).alignment(.center)
        .text("还没有评论哦~").end()
    private let commitButton = c_make_ex(UIButton.self)
        .image("Common_firstCommit").end()
    
    var commitBlock: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = .clear
        
        subviews{
            iconImageView
            titleLabel
            commitButton
        }
        
        iconImageView.top(0).width(96.0.Scale).height(131.0.Scale).centerHorizontally()
        titleLabel.leading(20).trailing(20)
        titleLabel.Top == iconImageView.Bottom + 8.0.Scale
        commitButton.width(72.0.Scale).height(26.0.Scale).centerHorizontally()
        commitButton.Top == titleLabel.Bottom + 16.0.Scale
        
        commitButton.addTarget(self, action: #selector(clickCommitButton), for: .touchUpInside)
    }
    
    @objc private func clickCommitButton(){
        commitBlock?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ClubEmptyArticleView: UIView {

    private let iconImageView = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).image("Common_articleEmpty").end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color("#2E3033").font(14.font_semiBold).alignment(.center).end()
    
    var titleString: String = "" {
        didSet{
            titleLabel.text = titleString
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = .clear
        
        subviews{
            iconImageView
            titleLabel

        }
        
        iconImageView.top(0).width(113.0.Scale).height(147.0.Scale).centerHorizontally()
        titleLabel.leading(20).trailing(20)
        titleLabel.Top == iconImageView.Bottom + 8.0.Scale
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ClubGameCommitEmptyView: UIView {

    private let iconImageView = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).image("Common_commitWhiteEmpty").end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color(.white).font(14.font_semiBold).alignment(.center)
        .text("还没有评论哦~").end()
    private let commitButton = c_make_ex(UIButton.self)
        .image("Common_firstCommit").end()
    
    var commitBlock: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = .clear
        
        subviews{
            iconImageView
            titleLabel
            commitButton
        }
        
        iconImageView.top(0).width(108.0.Scale).height(148.0.Scale).centerHorizontally()
        titleLabel.leading(20).trailing(20)
        titleLabel.Top == iconImageView.Bottom + 8.0.Scale
        commitButton.width(72.0.Scale).height(26.0.Scale).bottom(30.0.Scale).centerHorizontally()
        commitButton.Top == titleLabel.Bottom + 16.0.Scale
        
        commitButton.addTarget(self, action: #selector(clickCommitButton), for: .touchUpInside)
    }
    
    @objc private func clickCommitButton(){
        commitBlock?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ClubHomeEmptyDataView: UIView {

    private let iconImageView = c_make_ex(UIImageView.self)
        .image("Common_homeEmpty").end()
    private let reloadButton = c_make_ex(UIButton.self)
        .text("点击重试").bgColor("#FD8B00").color(.white)
        .font(16.font_medium).corner(18).end()
    
    var reloadBlock: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = .clear
        
        subviews{
            iconImageView
            reloadButton
        }
        
        iconImageView.top(0).width(160.0.Scale).height(180.0.Scale).centerHorizontally()
        reloadButton.width(160.0.Scale).height(36.0.Scale).centerHorizontally()
        reloadButton.Top == iconImageView.Bottom + 16.0.Scale
        
        reloadButton.addTarget(self, action: #selector(clickReloadButton), for: .touchUpInside)
    }
    
    @objc private func clickReloadButton(){
        reloadBlock?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
